home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / audio / rock / notetest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.1 KB  |  103 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    notetest - 
  19.  *        test the note code
  20.  *
  21.  *                Paul Haeberli - 1991 
  22.  */ 
  23. #include "math.h"
  24. #include "stdio.h"
  25. #include "gl.h"
  26. #include "device.h"
  27. #include "sample.h"
  28.  
  29. sample *s0, *s1, *s2;
  30. float frand();
  31.  
  32. #define SWINGA    0.0
  33. #define SWINGB    0.66666
  34.  
  35. #define ECHOQUANT    0.75
  36.  
  37. main(argc,argv)
  38. int argc;
  39. char **argv;
  40. {
  41.     int i, j, doecho;
  42.     sample *s;
  43.  
  44.     s0 = readsample("a.a");
  45.     s1 = readsample("b.a");
  46.     s2 = readsample("c.a");
  47.  
  48.     if(argc>2)
  49.     sethumanize(atof(argv[1]),atof(argv[2]));
  50.     else
  51.     sethumanize(0.005,0.3);
  52.     scalesample(s2,0.5);
  53.     beginnotes();
  54.     setbpm(110.0);
  55.     for(i=0; i<200; i++) {
  56.     flushnotes(i-4.0);
  57.     if(i<8 || i&1)
  58.         s = s0;
  59.     else
  60.         s = s1;
  61.     playnote(s,i+0.0,0.5);
  62.     if((random()%8)<4) {
  63.         playnote(s,i+1*ECHOQUANT,0.50);
  64.         playnote(s,i+2*ECHOQUANT,0.25);
  65.     }
  66.     if((i%8) == 0)
  67.         j = random()%6;
  68.     if(i<16)
  69.        j = 10;
  70.     switch(j) {
  71.         case 0:
  72.         playnote(s2,i+0.25,1.0);
  73.         playnote(s2,i+0.75,1.0);
  74.         break;
  75.         case 1:
  76.         playnote(s2,i+0.0,1.0);
  77.         playnote(s2,i+0.50,1.0);
  78.         break;
  79.         case 2:
  80.         playnote(s2,i+0.0,1.0);
  81.         playnote(s2,i+0.3333,1.0);
  82.         break;
  83.         case 3:
  84.         playnote(s2,i+0.25,1.0);
  85.         playnote(s2,i+0.75,1.0);
  86.         playnote(s2,i+0.0,1.0);
  87.         playnote(s2,i+0.50,1.0);
  88.         break;
  89.         case 4:
  90.         playnote(s2,i+0.25,1.0);
  91.         playnote(s2,i+0.50,1.0);
  92.         playnote(s2,i+0.75,1.0);
  93.         break;
  94.         case 5:
  95.         playnote(s2,i+0.0,1.0);
  96.         playnote(s2,i+0.66666,1.0);
  97.         break;
  98.     }
  99.     
  100.     }
  101.     endnotes();
  102. }
  103.